package com.sunrise.xdoc.converters;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import java.text.DecimalFormat;

/**
 * The Class VNDConverter.
 *
 * @author Nguyen Duc Dung
 * @since 5/25/13 4:07 PM
 */
@FacesConverter("VNDConverter")
public class VNDConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        DecimalFormat decimalFormat = new DecimalFormat("###,###.### VND");
        return decimalFormat.format(value);
    }
}
